-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4376] Add support for URLs to specify a selection of elements in the workbench #4461
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole code in EditProjectView should be extracted in a dedicated hook
useEffect(() => { | ||
onSelectionChanged(selection); | ||
}, [selection]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems very odd, the workbench is retrieving the selection from above and now it need to tell someone above it that the selection has changed. It should be determined above the workbench. I don't think this component has to changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this here because when defining the same effect in EditProjectView, I was not seeing any changes in the selection, so we never had the chance to react to it.
@@ -56,6 +57,7 @@ export type WorkbenchProps = { | |||
editingContextId: string; | |||
initialRepresentationSelected: RepresentationMetadata | null; | |||
onRepresentationSelected: (representation: RepresentationMetadata | null) => void; | |||
onSelectionChanged: (selection: Selection | null) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(same as above)
packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/EditProjectView.tsx
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
function updateUrlSearchParamsWithSelection(setUrlSearchParams: SetURLSearchParams, selection: Selection) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't propagate hook functions like that, just compose your hook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tweaked a bit my implementation to rely on useSelection() hook, but the URLSearchparams hook requires a Router context because it relies on useLocation hook. Not sure how to work around this otherwise.
packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/EditProjectView.tsx
Outdated
Show resolved
Hide resolved
packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/EditProjectView.tsx
Outdated
Show resolved
Hide resolved
Not "a representation" but specifically a diagram, it's a bug in the code of the selection of diagrams
That's an issue, we will have to look into this |
For the second issue, it should be possible to set the selection in |
Bug: eclipse-sirius#4376 Signed-off-by: Florent Latombe <[email protected]>
Bug: eclipse-sirius#4376 Signed-off-by: Florent Latombe <[email protected]>
c54cb99
to
9fba3e4
Compare
* When the workbench selection changes, the URL search parameters are now automatically updated to encode the contents of the selection (id and kind). * Reversely, when resolving a URL with such search parameters, the workbench selection is set to those specified elements. Bug: eclipse-sirius#4376 Signed-off-by: Florent Latombe <[email protected]>
There was an issue where when resolving a URL with a selection and an open diagram, the selection was not being applied graphically in the diagram because at the time the selection is applied, the diagram exists but has no nodes or edges. This is a workaround to make sure the selection gets applied during the first render *after* the nodes and edges have been created. Bug: eclipse-sirius#4376 Signed-off-by: Florent Latombe <[email protected]>
Can you please review this PR and let me know:
Note: there are 2 small remaining issues I found while testing:
Selecting a representation leads to an empty selection
This is an existing issue which impacts us a bit. I believe it's out of the scope of this PR as it already existed and is not blocking, but it could be good to have a dedicated issue to track this.
To reproduce:
in the diagram (they can be selected either in the diagram or through
the 'Explorer' tree)
Graphical selection in diagram is not performed when resolving a URL with a selection.
This one is a bit more annoying.
To reproduce:
useDiagramSelection
that depends onselection
. When it is executed for the first time, the diagram does not yet have its nodes and edges so nothing gets selected. Adding a dependency from this effect to the getNodes and getEdges leads to flickering between the current and previous selections.Pull request template
General purpose
What is the main goal of this pull request?
Project management
priority:
andpr:
labels been added to the pull request? (In case of doubt, start with the labelspriority: low
andpr: to review later
)area:
,difficulty:
,type:
)CHANGELOG.adoc
been updated to reference the relevant issues?CHANGELOG.adoc
? (Including changes in the GraphQL API)CHANGELOG.adoc
? For example indoc/screenshots/2022.5.0-my-new-feature.png
Architectural decision records (ADR)
[doc]
?CHANGELOG.adoc
?Dependencies
CHANGELOG.adoc
?CHANGELOG.adoc
?Frontend
This section is not relevant if your contribution does not come with changes to the frontend.
General purpose
Typing
We need to improve the typing of our code, as such, we require every contribution to come with proper TypeScript typing for both changes contributing new files and those modifying existing files.
Please ensure that the following statements are true for each file created or modified (this may require you to improve code outside of your contribution).
useMutation<DATA_TYPE, VARIABLE_TYPE>(…)
useQuery<DATA_TYPE, VARIABLE_TYPE>(…)
useSubscription<DATA_TYPE, VARIABLE_TYPE>(…)
useMachine<CONTEXT_TYPE, EVENTS_TYPE>(…)
useState<STATE_TYPE>(…)
?.
(if the GraphQL API specifies that a field cannot benull
, do not treat it has potentiallynull
for example)let diagram: Diagram | null = null;
)Backend
This section is not relevant if your contribution does not come with changes to the backend.
General purpose
Architecture
Review
How to test this PR?